<%@ page import="mybatis.yang.Books" %>
<%@ page import="mybatis.dao.Mybatis" %>
<%@ page import="java.util.List" %>
<%@ page import="mybatis.yang.Order_product" %>
<%@ page import="mybatis.yang.Order" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/11/21
  Time: 21:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
      <%
          //先将order_product表里面的商品id,数量.拿出来,放到list集合里面
          Mybatis mybatis=new Mybatis();
          List<Order_product> list=mybatis.select_order_product();
          Order o=new Order();
          String userid= (String) request.getSession().getAttribute("userid");
          for (Order_product order:list) {
              System.out.println(order);
              o.setOrder_product_id(order.getOrder_id());
              String price=mybatis.selectBookID(order.getProduct_id());
              String num=order.getNum();
              int price1=Integer.parseInt(price);
              int num1=Integer.parseInt(num);
              String money=(price1*num1)+"";
              o.setMoney(money);
              o.setUser_id(userid);
              o.setAddress("xian");
              mybatis.insert_order(o);
          }
          String username= (String) request.getSession().getAttribute("username");

      %>
        你的姓名:<%=(String) request.getSession().getAttribute("username")%><br>

</body>
</html>
